package com.ruoyi.supervise.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.supervise.domain.CompletionRecordApply;
import com.ruoyi.supervise.domain.CompletionRecordTable;
import com.ruoyi.supervise.mapper.CompletionRecordMapper;
import com.ruoyi.supervise.service.ICompletionRecordService;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;

/**
 * @ClassName: MyTestServiceImpl
 * @Description: 测试从数据源
 * @Author wtj
 * @DateTime 2020年3月9日 上午10:41:31
 */
@Service
@DataSource(value = DataSourceType.SLAVE)
public class CompletionRecordServiceImpl implements ICompletionRecordService 
{
    @Autowired
    private CompletionRecordMapper completionRecordMapper;

	@Override
	public List<CompletionRecordTable> selectCompletionRecordTableList(CompletionRecordTable completionRecordTable) {
		if(StringUtils.isEmpty(completionRecordTable.getBeginReportTime()) && !StringUtils.isEmpty(completionRecordTable.getEndReportTime())) {
			completionRecordTable.setBeginReportTime("1970-01-01");
		}else if(!StringUtils.isEmpty(completionRecordTable.getBeginReportTime()) && StringUtils.isEmpty(completionRecordTable.getEndReportTime())) {
			completionRecordTable.setEndReportTime(DateUtil.format(new Date(), DatePattern.NORM_DATE_PATTERN));
		}
		return completionRecordMapper.selectCompletionRecordTableList(completionRecordTable);
	}

	@Override
	public CompletionRecordApply selectCompletionRecordApplyByGuid(String guid) {
		// TODO Auto-generated method stub
		return completionRecordMapper.selectCompletionRecordApplyByGuid(guid);
	}

	@Override
	public String selectCompletionRecordStateByEngGuid(String engineeringInfoGuids) {
		// TODO Auto-generated method stub
		return completionRecordMapper.selectCompletionRecordStateByEngGuid(engineeringInfoGuids);
	}
}
